﻿using System;
using System.Collections.Generic;
using System.Reflection;

namespace Marmat.Forms
{
    public partial class TabFormPanel
    {


        /// <summary>
    /// 设置窗体是否允许关闭
    /// </summary>
    /// <param name="frm">要设置属性的窗体</param>
    /// <param name="Close">是否允许关闭，true为允许关闭，false 为不允许关闭。</param>
    /// <remarks></remarks>
        public void SetClose(System.Windows.Forms.Form frm, bool Close)
        {
            if (this.CloseCollection.ContainsKey(frm))
            {
                this.CloseCollection[frm] = Close;
            }
            else
            {
                this.CloseCollection.Add(frm, Close);
            }
        }
        /// <summary>
    /// 获取窗体是否允许关闭
    /// </summary>
    /// <param name="frm">要获取属性的窗体</param>
    /// <remarks></remarks>
        public bool GetClose(System.Windows.Forms.Form frm)
        {
            if (this.CloseCollection.ContainsKey(frm))
            {
                return this.CloseCollection[frm];
            }

            return true;
        }

        /// <summary>
    /// 获取关闭属性的字典集合
    /// </summary>
    /// <value></value>
    /// <returns></returns>
    /// <remarks></remarks>
        public Dictionary<System.Windows.Forms.Form, bool> CloseCollection
        {
            get
            {
                if (this.m_CloseCollection is null)
                {
                    this.m_CloseCollection = new Dictionary<System.Windows.Forms.Form, bool>();
                }

                return this.m_CloseCollection;
            }
        }

        private Dictionary<System.Windows.Forms.Form, bool> m_CloseCollection;

        //public System.Windows.Forms.Form CreateForm(object Item, Type FormType, params object[] args)
        //{
        //    if (Item.Tag is null || ((System.Windows.Forms.Form)Item.Tag).IsDisposed)
        //    {
        //        System.Windows.Forms.Form frm = (System.Windows.Forms.Form)FormType.Assembly.CreateInstance(FormType.FullName, true, BindingFlags.Default, null, args, null, null);
        //        if (frm is object)
        //        {
        //            Item.Tag = frm;
        //            this.Forms.Add(frm);
        //            return frm;
        //        }
        //    }
        //    else
        //    {
        //        this.SelectedForm = (System.Windows.Forms.Form)Item.Tag;
        //        return (System.Windows.Forms.Form)Item.Tag;
        //    }

        //    return null;
        //}
    }
}